//
//  HHLVistorView.swift
//  SwiftWeibo
//
//  Created by 呆萌诺 on 15/10/26.
//  Copyright © 2015年 呆萌诺. All rights reserved.
//

import UIKit

class HHLVistorView: UIView {

    //MARK: - 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        prepareUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    func prepareUI() {
        //添加子控件
        self.addSubview(iconView)
        self.addSubview(hourseView)
        self.addSubview(messageLabel)
        self.addSubview(registerButton)
        self.addSubview(loginButton)
        
        
        //设置约束，取消sizeclasses 防止对autoLayout影响
        iconView.translatesAutoresizingMaskIntoConstraints = false
        hourseView.translatesAutoresizingMaskIntoConstraints = false
        messageLabel.translatesAutoresizingMaskIntoConstraints = false
        registerButton.translatesAutoresizingMaskIntoConstraints = false
        loginButton.translatesAutoresizingMaskIntoConstraints = false
        
        
        //创建约束
        /*
        AnyObject:控件
        NSLayoutAttribute:Layout(属性) eg  case Left，Right，Top，Bottom，Width，Height，CenterX，CenterY
        NSLayoutRelation(关系)
        multiplier(乘及倍数)
        constant(相对距离)
        */
        self.addConstraint(NSLayoutConstraint(item: iconView, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: .CenterX, multiplier: 1.0, constant: 0))
        
        
        self.addConstraint(NSLayoutConstraint(item: iconView, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: .CenterY, multiplier: 1.0, constant: 0))
        
    }
    
    
    
    
    
    
    //MARK: - Setter & Getter
    ///转轮
    private lazy var iconView : UIImageView = {
        
        let imageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
        imageView.sizeToFit()

        return imageView
    }()
    
    ///小房子
    private lazy var hourseView : UIImageView = {
        let imageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
        imageView.sizeToFit()
        
        return imageView
    }()
    
    
    ///消息文字
    private lazy var messageLabel : UILabel = {
        let label = UILabel()
        label.text = "关注一些人,看看有什么惊喜,关注一些人,看看有什么惊喜,关注一些人,看看有什么惊喜"
        label.numberOfLines = 0
        label.sizeToFit()
        return label
    }()
    
    
    ///注册按钮
    private lazy var registerButton : UIButton = {
       let button = UIButton()
        
        button.setTitle("注册", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
        
        button.setImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
        
        button.sizeToFit()
        
        return button
    }()
    
    ///登录按钮
    private lazy var loginButton : UIButton = {
       let button = UIButton()
        
        button.setTitle("注册", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
        
        button.sizeToFit()
        
        return button
        
    }()
    

}
